0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 821 ms)
↳10 BOUNDS(1, n^3)
minus(s(x), y) → if(gt(s(x), y), x, y)
if(true, x, y) → s(minus(x, y))
if(false, x, y) → 0
ge(x, 0) → true
ge(0, s(x)) → false
ge(s(x), s(y)) → ge(x, y)
gt(0, y) → false
gt(s(x), 0) → true
gt(s(x), s(y)) → gt(x, y)
div(x, y) → if1(ge(x, y), x, y)
if1(true, x, y) → if2(gt(y, 0), x, y)
if1(false, x, y) → 0
if2(true, x, y) → s(div(minus(x, y), y))
if2(false, x, y) → 0
minus(s(x), y) → if(gt(s(x), y), x, y) [1]
if(true, x, y) → s(minus(x, y)) [1]
if(false, x, y) → 0 [1]
ge(x, 0) → true [1]
ge(0, s(x)) → false [1]
ge(s(x), s(y)) → ge(x, y) [1]
gt(0, y) → false [1]
gt(s(x), 0) → true [1]
gt(s(x), s(y)) → gt(x, y) [1]
div(x, y) → if1(ge(x, y), x, y) [1]
if1(true, x, y) → if2(gt(y, 0), x, y) [1]
if1(false, x, y) → 0 [1]
if2(true, x, y) → s(div(minus(x, y), y)) [1]
if2(false, x, y) → 0 [1]
minus(s(x), y) → if(gt(s(x), y), x, y) [1]
if(true, x, y) → s(minus(x, y)) [1]
if(false, x, y) → 0 [1]
ge(x, 0) → true [1]
ge(0, s(x)) → false [1]
ge(s(x), s(y)) → ge(x, y) [1]
gt(0, y) → false [1]
gt(s(x), 0) → true [1]
gt(s(x), s(y)) → gt(x, y) [1]
div(x, y) → if1(ge(x, y), x, y) [1]
if1(true, x, y) → if2(gt(y, 0), x, y) [1]
if1(false, x, y) → 0 [1]
if2(true, x, y) → s(div(minus(x, y), y)) [1]
if2(false, x, y) → 0 [1]
minus :: s:0 → s:0 → s:0 s :: s:0 → s:0 if :: true:false → s:0 → s:0 → s:0 gt :: s:0 → s:0 → true:false true :: true:false false :: true:false 0 :: s:0 ge :: s:0 → s:0 → true:false div :: s:0 → s:0 → s:0 if1 :: true:false → s:0 → s:0 → s:0 if2 :: true:false → s:0 → s:0 → s:0 |
minus(v0, v1) → null_minus [0]
ge(v0, v1) → null_ge [0]
gt(v0, v1) → null_gt [0]
if(v0, v1, v2) → null_if [0]
if1(v0, v1, v2) → null_if1 [0]
if2(v0, v1, v2) → null_if2 [0]
null_minus, null_ge, null_gt, null_if, null_if1, null_if2
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
true => 2
false => 1
0 => 0
null_minus => 0
null_ge => 0
null_gt => 0
null_if => 0
null_if1 => 0
null_if2 => 0
div(z, z') -{ 1 }→ if1(ge(x, y), x, y) :|: x >= 0, y >= 0, z = x, z' = y
ge(z, z') -{ 1 }→ ge(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
ge(z, z') -{ 1 }→ 2 :|: x >= 0, z = x, z' = 0
ge(z, z') -{ 1 }→ 1 :|: z' = 1 + x, x >= 0, z = 0
ge(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
gt(z, z') -{ 1 }→ gt(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
gt(z, z') -{ 1 }→ 2 :|: x >= 0, z = 1 + x, z' = 0
gt(z, z') -{ 1 }→ 1 :|: y >= 0, z = 0, z' = y
gt(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
if(z, z', z'') -{ 1 }→ 0 :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
if(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
if(z, z', z'') -{ 1 }→ 1 + minus(x, y) :|: z = 2, z' = x, z'' = y, x >= 0, y >= 0
if1(z, z', z'') -{ 1 }→ if2(gt(y, 0), x, y) :|: z = 2, z' = x, z'' = y, x >= 0, y >= 0
if1(z, z', z'') -{ 1 }→ 0 :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
if1(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
if2(z, z', z'') -{ 1 }→ 0 :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
if2(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
if2(z, z', z'') -{ 1 }→ 1 + div(minus(x, y), y) :|: z = 2, z' = x, z'' = y, x >= 0, y >= 0
minus(z, z') -{ 1 }→ if(gt(1 + x, y), x, y) :|: x >= 0, y >= 0, z = 1 + x, z' = y
minus(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
eq(start(V, V1, V4),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[if(V, V1, V4, Out)],[V >= 0,V1 >= 0,V4 >= 0]). eq(start(V, V1, V4),0,[ge(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[gt(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[div(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[if1(V, V1, V4, Out)],[V >= 0,V1 >= 0,V4 >= 0]). eq(start(V, V1, V4),0,[if2(V, V1, V4, Out)],[V >= 0,V1 >= 0,V4 >= 0]). eq(minus(V, V1, Out),1,[gt(1 + V2, V3, Ret0),if(Ret0, V2, V3, Ret)],[Out = Ret,V2 >= 0,V3 >= 0,V = 1 + V2,V1 = V3]). eq(if(V, V1, V4, Out),1,[minus(V5, V6, Ret1)],[Out = 1 + Ret1,V = 2,V1 = V5,V4 = V6,V5 >= 0,V6 >= 0]). eq(if(V, V1, V4, Out),1,[],[Out = 0,V1 = V7,V4 = V8,V = 1,V7 >= 0,V8 >= 0]). eq(ge(V, V1, Out),1,[],[Out = 2,V9 >= 0,V = V9,V1 = 0]). eq(ge(V, V1, Out),1,[],[Out = 1,V1 = 1 + V10,V10 >= 0,V = 0]). eq(ge(V, V1, Out),1,[ge(V11, V12, Ret2)],[Out = Ret2,V1 = 1 + V12,V11 >= 0,V12 >= 0,V = 1 + V11]). eq(gt(V, V1, Out),1,[],[Out = 1,V13 >= 0,V = 0,V1 = V13]). eq(gt(V, V1, Out),1,[],[Out = 2,V14 >= 0,V = 1 + V14,V1 = 0]). eq(gt(V, V1, Out),1,[gt(V15, V16, Ret3)],[Out = Ret3,V1 = 1 + V16,V15 >= 0,V16 >= 0,V = 1 + V15]). eq(div(V, V1, Out),1,[ge(V17, V18, Ret01),if1(Ret01, V17, V18, Ret4)],[Out = Ret4,V17 >= 0,V18 >= 0,V = V17,V1 = V18]). eq(if1(V, V1, V4, Out),1,[gt(V19, 0, Ret02),if2(Ret02, V20, V19, Ret5)],[Out = Ret5,V = 2,V1 = V20,V4 = V19,V20 >= 0,V19 >= 0]). eq(if1(V, V1, V4, Out),1,[],[Out = 0,V1 = V21,V4 = V22,V = 1,V21 >= 0,V22 >= 0]). eq(if2(V, V1, V4, Out),1,[minus(V23, V24, Ret10),div(Ret10, V24, Ret11)],[Out = 1 + Ret11,V = 2,V1 = V23,V4 = V24,V23 >= 0,V24 >= 0]). eq(if2(V, V1, V4, Out),1,[],[Out = 0,V1 = V25,V4 = V26,V = 1,V25 >= 0,V26 >= 0]). eq(minus(V, V1, Out),0,[],[Out = 0,V27 >= 0,V28 >= 0,V = V27,V1 = V28]). eq(ge(V, V1, Out),0,[],[Out = 0,V29 >= 0,V30 >= 0,V = V29,V1 = V30]). eq(gt(V, V1, Out),0,[],[Out = 0,V31 >= 0,V32 >= 0,V = V31,V1 = V32]). eq(if(V, V1, V4, Out),0,[],[Out = 0,V33 >= 0,V4 = V34,V35 >= 0,V = V33,V1 = V35,V34 >= 0]). eq(if1(V, V1, V4, Out),0,[],[Out = 0,V36 >= 0,V4 = V37,V38 >= 0,V = V36,V1 = V38,V37 >= 0]). eq(if2(V, V1, V4, Out),0,[],[Out = 0,V39 >= 0,V4 = V40,V41 >= 0,V = V39,V1 = V41,V40 >= 0]). input_output_vars(minus(V,V1,Out),[V,V1],[Out]). input_output_vars(if(V,V1,V4,Out),[V,V1,V4],[Out]). input_output_vars(ge(V,V1,Out),[V,V1],[Out]). input_output_vars(gt(V,V1,Out),[V,V1],[Out]). input_output_vars(div(V,V1,Out),[V,V1],[Out]). input_output_vars(if1(V,V1,V4,Out),[V,V1,V4],[Out]). input_output_vars(if2(V,V1,V4,Out),[V,V1,V4],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [ge/3]
1. recursive : [gt/3]
2. recursive : [if/4,minus/3]
3. recursive : [ (div)/3,if1/4,if2/4]
4. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into ge/3
1. SCC is partially evaluated into gt/3
2. SCC is partially evaluated into minus/3
3. SCC is partially evaluated into (div)/3
4. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations ge/3
* CE 29 is refined into CE [30]
* CE 26 is refined into CE [31]
* CE 27 is refined into CE [32]
* CE 28 is refined into CE [33]
### Cost equations --> "Loop" of ge/3
* CEs [33] --> Loop 15
* CEs [30] --> Loop 16
* CEs [31] --> Loop 17
* CEs [32] --> Loop 18
### Ranking functions of CR ge(V,V1,Out)
* RF of phase [15]: [V,V1]
#### Partial ranking functions of CR ge(V,V1,Out)
* Partial RF of phase [15]:
- RF of loop [15:1]:
V
V1
### Specialization of cost equations gt/3
* CE 16 is refined into CE [34]
* CE 14 is refined into CE [35]
* CE 13 is refined into CE [36]
* CE 15 is refined into CE [37]
### Cost equations --> "Loop" of gt/3
* CEs [37] --> Loop 19
* CEs [34] --> Loop 20
* CEs [35] --> Loop 21
* CEs [36] --> Loop 22
### Ranking functions of CR gt(V,V1,Out)
* RF of phase [19]: [V,V1]
#### Partial ranking functions of CR gt(V,V1,Out)
* Partial RF of phase [19]:
- RF of loop [19:1]:
V
V1
### Specialization of cost equations minus/3
* CE 17 is refined into CE [38,39,40,41]
* CE 18 is refined into CE [42]
* CE 20 is refined into CE [43]
* CE 19 is refined into CE [44,45]
### Cost equations --> "Loop" of minus/3
* CEs [45] --> Loop 23
* CEs [44] --> Loop 24
* CEs [38,39,40,41,42,43] --> Loop 25
### Ranking functions of CR minus(V,V1,Out)
* RF of phase [23]: [V-1,V-V1]
* RF of phase [24]: [V]
#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [23]:
- RF of loop [23:1]:
V-1
V-V1
* Partial RF of phase [24]:
- RF of loop [24:1]:
V
### Specialization of cost equations (div)/3
* CE 21 is refined into CE [46,47,48,49]
* CE 22 is refined into CE [50]
* CE 24 is refined into CE [51,52,53,54,55]
* CE 25 is refined into CE [56,57]
* CE 23 is refined into CE [58,59]
### Cost equations --> "Loop" of (div)/3
* CEs [59] --> Loop 26
* CEs [58] --> Loop 27
* CEs [46,47,50,52] --> Loop 28
* CEs [48,49,51,53,54,55,56,57] --> Loop 29
### Ranking functions of CR div(V,V1,Out)
* RF of phase [26]: [V-1,V-V1]
#### Partial ranking functions of CR div(V,V1,Out)
* Partial RF of phase [26]:
- RF of loop [26:1]:
V-1
V-V1
### Specialization of cost equations start/3
* CE 2 is refined into CE [60,61,62]
* CE 4 is refined into CE [63]
* CE 6 is refined into CE [64,65,66,67,68]
* CE 7 is refined into CE [69,70,71,72,73,74]
* CE 8 is refined into CE [75,76,77]
* CE 3 is refined into CE [78]
* CE 5 is refined into CE [79]
* CE 9 is refined into CE [80,81,82]
* CE 10 is refined into CE [83,84,85,86,87]
* CE 11 is refined into CE [88,89,90,91,92]
* CE 12 is refined into CE [93,94,95,96]
### Cost equations --> "Loop" of start/3
* CEs [80,84,89] --> Loop 30
* CEs [60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77] --> Loop 31
* CEs [79] --> Loop 32
* CEs [78,81,82,83,85,86,87,88,90,91,92,93,94,95,96] --> Loop 33
### Ranking functions of CR start(V,V1,V4)
#### Partial ranking functions of CR start(V,V1,V4)
Computing Bounds
=====================================
#### Cost of chains of ge(V,V1,Out):
* Chain [[15],18]: 1*it(15)+1
Such that:it(15) =< V
with precondition: [Out=1,V>=1,V1>=V+1]
* Chain [[15],17]: 1*it(15)+1
Such that:it(15) =< V1
with precondition: [Out=2,V1>=1,V>=V1]
* Chain [[15],16]: 1*it(15)+0
Such that:it(15) =< V1
with precondition: [Out=0,V>=1,V1>=1]
* Chain [18]: 1
with precondition: [V=0,Out=1,V1>=1]
* Chain [17]: 1
with precondition: [V1=0,Out=2,V>=0]
* Chain [16]: 0
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of gt(V,V1,Out):
* Chain [[19],22]: 1*it(19)+1
Such that:it(19) =< V
with precondition: [Out=1,V>=1,V1>=V]
* Chain [[19],21]: 1*it(19)+1
Such that:it(19) =< V1
with precondition: [Out=2,V1>=1,V>=V1+1]
* Chain [[19],20]: 1*it(19)+0
Such that:it(19) =< V1
with precondition: [Out=0,V>=1,V1>=1]
* Chain [22]: 1
with precondition: [V=0,Out=1,V1>=0]
* Chain [21]: 1
with precondition: [V1=0,Out=2,V>=1]
* Chain [20]: 0
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of minus(V,V1,Out):
* Chain [[24],25]: 3*it(24)+2*s(4)+3
Such that:aux(1) =< V-Out
it(24) =< Out
s(4) =< aux(1)
with precondition: [V1=0,Out>=1,V>=Out]
* Chain [[23],25]: 3*it(23)+2*s(3)+2*s(4)+1*s(9)+3
Such that:aux(1) =< V-Out
it(23) =< Out
aux(4) =< V1
s(4) =< aux(1)
s(3) =< aux(4)
s(9) =< it(23)*aux(4)
with precondition: [V1>=1,Out>=1,V>=Out+V1]
* Chain [25]: 2*s(3)+2*s(4)+3
Such that:aux(1) =< V
aux(2) =< V1
s(4) =< aux(1)
s(3) =< aux(2)
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of div(V,V1,Out):
* Chain [[26],29]: 8*it(26)+4*s(10)+7*s(14)+3*s(31)+1*s(33)+4
Such that:aux(10) =< V-V1
aux(12) =< V
aux(13) =< V1
it(26) =< aux(12)
s(14) =< aux(12)
s(10) =< aux(13)
it(26) =< aux(10)
s(31) =< it(26)*aux(10)
s(33) =< s(31)*aux(13)
with precondition: [V1>=1,Out>=1,V>=Out+V1]
* Chain [[26],27,29]: 8*it(26)+7*s(10)+7*s(30)+3*s(31)+1*s(33)+12
Such that:aux(10) =< V-V1
aux(16) =< V
aux(17) =< V1
it(26) =< aux(16)
s(10) =< aux(17)
s(30) =< aux(16)
it(26) =< aux(10)
s(31) =< it(26)*aux(10)
s(33) =< s(31)*aux(17)
with precondition: [V1>=1,Out>=2,V+2>=2*V1+Out]
* Chain [29]: 4*s(10)+2*s(14)+4
Such that:aux(5) =< V
aux(6) =< V1
s(14) =< aux(5)
s(10) =< aux(6)
with precondition: [Out=0,V>=0,V1>=0]
* Chain [28]: 5
with precondition: [V1=0,Out=0,V>=0]
* Chain [27,29]: 7*s(10)+2*s(39)+12
Such that:s(37) =< V
aux(15) =< V1
s(10) =< aux(15)
s(39) =< s(37)
with precondition: [Out=1,V1>=1,V>=V1]
#### Cost of chains of start(V,V1,V4):
* Chain [33]: 27*s(48)+30*s(49)+1*s(55)+16*s(73)+6*s(76)+2*s(77)+12
Such that:aux(19) =< V
aux(20) =< V-V1
aux(21) =< V1
s(48) =< aux(19)
s(49) =< aux(21)
s(73) =< aux(19)
s(73) =< aux(20)
s(76) =< s(73)*aux(20)
s(77) =< s(76)*aux(21)
s(55) =< s(48)*aux(21)
with precondition: [V>=0,V1>=0]
* Chain [32]: 1
with precondition: [V=1,V1>=0,V4>=0]
* Chain [31]: 99*s(89)+76*s(90)+9*s(100)+32*s(124)+12*s(127)+4*s(128)+18
Such that:aux(43) =< V1
aux(44) =< V1-V4
aux(45) =< V4
s(89) =< aux(43)
s(90) =< aux(45)
s(100) =< s(89)*aux(45)
s(124) =< aux(43)
s(124) =< aux(44)
s(127) =< s(124)*aux(44)
s(128) =< s(127)*aux(45)
with precondition: [V=2,V1>=0,V4>=0]
* Chain [30]: 5*s(220)+3
Such that:aux(46) =< V
s(220) =< aux(46)
with precondition: [V1=0,V>=0]
Closed-form bounds of start(V,V1,V4):
-------------------------------------
* Chain [33] with precondition: [V>=0,V1>=0]
- Upper bound: 43*V+30*V1+12+V1*V+2*V1*nat(V-V1)*V+nat(V-V1)*6*V
- Complexity: n^3
* Chain [32] with precondition: [V=1,V1>=0,V4>=0]
- Upper bound: 1
- Complexity: constant
* Chain [31] with precondition: [V=2,V1>=0,V4>=0]
- Upper bound: 131*V1+76*V4+18+9*V4*V1+4*V4*nat(V1-V4)*V1+nat(V1-V4)*12*V1
- Complexity: n^3
* Chain [30] with precondition: [V1=0,V>=0]
- Upper bound: 5*V+3
- Complexity: n
### Maximum cost of start(V,V1,V4): max([131*V1+17+nat(V4)*76+nat(V4)*9*V1+nat(V4)*4*nat(V1-V4)*V1+nat(V1-V4)*12*V1,38*V+30*V1+9+V1*V+2*V1*nat(V-V1)*V+nat(V-V1)*6*V+ (5*V+2)])+1
Asymptotic class: n^3
* Total analysis performed in 633 ms.